//
//  UserDecoratedHTTPRequestProvider.m
//  iPhoneMyRailApp
//
//  Created by Christopher Anderson on 01/11/2008.
//  Copyright 2008 __MyCompanyName__. All rights reserved.
//

#import "UserDecoratedHTTPRequest.h"


@implementation UserDecoratedHTTPRequest

- (NSString*) makeRequest:(NSString*)urlString silentFailure:(BOOL)silent {
	
	[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
    
    NSURL *url = [NSURL URLWithString:urlString];    
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
	[request setValue:@"1.1" forHTTPHeaderField:@"X-TarPipe-Version"];
	[request setValue:[[UIDevice currentDevice] uniqueIdentifier] forHTTPHeaderField:@"X-TarPipe-UID"];
	
    
    NSError *error;
    NSHTTPURLResponse *response;
    NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
	
	[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
	
	if([response statusCode]==200) {
		return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
	} 
	return nil;
}

@end
